import java.util.*;
import java.util.regex.*;
import java.text.*;
import java.math.*;
import java.awt.geom.*;

public class PointErasingTwo {
	public int getMaximum(int[] y) {
		int mmax = 0;
		for (int i = 0; i < y.length - 1; i++) {
			for (int j = i + 1; j < y.length; j++) {
				int ymin = Math.min(y[i], y[j]);
				int ymax = Math.max(y[i], y[j]);
				int tmp = 0;
				for (int p = 0; p < y.length; p++) {
					if (p > i && p < j && y[p] > ymin && y[p] < ymax)
						tmp++;
					mmax = Math.max(mmax, tmp);
				}
			}
		}
		return mmax;
	}

	// <%:testing-code%>
}
// Powered by [KawigiEdit] 2.0!